package com.cdut.hezhisu.dribbble.view;
import android.content.Context;
import android.graphics.Color;
import android.text.ClipboardManager;
import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.util.AttributeSet;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.cdut.hezhisu.dribbble.R;


public class TagView extends RelativeLayout{

	private Context mContext;
	private CircleColorView mBtnColor;
	public TagView(Context context, AttributeSet attrs) {
		super(context, attrs);
	}

	public TagView(Context context) {
		super(context);
	}
	
	public void init(final Context context, final String color){

		mContext = context;
		LayoutInflater.from(context).inflate(R.layout.layout_tagview, this, true);
		mBtnColor = (CircleColorView) findViewById(R.id.btn_color);
		mBtnColor.setColor(Color.parseColor(color));
		mBtnColor.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				copy(color,context);
				Toast.makeText(context,"色值已复制！",Toast.LENGTH_SHORT).show();
			}
		});
	}


	/**
	 * 实现文本复制功能
	 * add by wangqianzhou
	 * @param content
	 */
	public void copy(String content, Context context)
	{
		ClipboardManager cmb = (ClipboardManager)context.getSystemService(Context.CLIPBOARD_SERVICE);
		cmb.setText(content.trim());
	}

}
